//
//  MainTabbarController.m
//  NewCP
//
//  Created by 刘萍 on 2018/7/16.
//  Copyright © 2018年 李英新. All rights reserved.
//

#import "MainTabbarController.h"
#import "MainNavigationController.h"
#import "MainController01.h"
#import "MainController02.h"
#import "MainController03.h"

@interface MainTabbarController ()

@end

@implementation MainTabbarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    MainController01 * child01 =[[MainController01 alloc] init];
    [self addChildViewController:child01 title:@"首页" image:@"MainTabbarNone1" selectedImage:@"MainTabbarSelect1"];
    
    MainController02 * child02 = [[MainController02 alloc] init];
    [self addChildViewController:child02 title:@"账单" image:@"MainTabbarNone2" selectedImage:@"MainTabbarSelect2"];
    
    MainController03 * child03 = [[MainController03 alloc] init];
    [self addChildViewController:child03 title:@"我的" image:@"MainTabbarNone3" selectedImage:@"MainTabbarSelect3"];
    
    
}
/**
 添加主视图
 @param vc 视图
 @param title 文字
 @param imageName 图片
 @param selectImage 点击的图片
 */

- (void)addChildViewController:(UIViewController *)vc title:(NSString *)title image:(NSString *)imageName selectedImage:(NSString *)selectImage{
    
    MainNavigationController *nav = [[MainNavigationController alloc] initWithRootViewController:vc];
    nav.tabBarItem.title = title;
    nav.tabBarItem.image = [UIImage imageNamed:imageName] ;
    nav.tabBarItem.selectedImage = [[UIImage imageNamed:selectImage]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    // 设置 tabbarItem 选中状态下的文字颜色(不被系统默认渲染,显示文字自定义颜色)
    NSDictionary *dictHome = [NSDictionary dictionaryWithObject:[UIColor colorWithRed:232/255.0 green:54/255.0 blue:70/255.0 alpha:1.0] forKey:NSForegroundColorAttributeName];
    [nav.tabBarItem setTitleTextAttributes:dictHome forState:UIControlStateSelected];
    [self addChildViewController:nav];
    
}


- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
    item.badgeValue = nil;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
